package eirkdbd.lab1.membership.functions.helpers;

import java.util.Collections;
import java.util.List;

/**
 * Provides basic operations on fuzzy values
 *
 */
public class FuzzyOperations {	

	/**
	 * Returns minimum of two fuzzy values <br>
	 * Values must be between 0 and 1
	 */
	public static double min(double a, double b){
		if( a<0 || b <0 || a> 1 || b > 1)
			throw new IllegalArgumentException("Fuzzy logic must be between 0 and 1");
		if (a < b)
			return a;
		return b;
	}
	
	/**
	 * Returns maximum of two fuzzy values <br>
	 * Values must be between 0 and 1
	 */
	public static double max(double a, double b){
		if( a<0 || b <0 || a> 1 || b > 1)
			throw new IllegalArgumentException("Fuzzy logic must be between 0 and 1");
		if (a > b)
			return a;
		return b;
	}
	
	/**
	 * Returns maximum of fuzzy values list <br>
	 * Values must be between 0 and 1
	 */
	public static double max(List<Double> values){
		return Collections.max(values);
	}

}
